package com.zhuiYun.project.api.ordersAfterSales.controller;


import com.zhuiYun.project.annotation.OptLog;
import com.zhuiYun.project.api.handworkDiy.model.HandworkDiyModel;
import com.zhuiYun.project.api.order.model.CommorderModel;
import com.zhuiYun.project.api.ordersAfterSales.entity.OrdersRetreat;
import com.zhuiYun.project.api.ordersAfterSales.service.ordersRetreatService;
import com.zhuiYun.project.common.response.CommonConstants;
import com.zhuiYun.project.common.response.CommonResult;
import com.zhuiYun.project.util.pageUtil.PageRequest;
import com.zhuiYun.project.util.pageUtil.PageResult;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@CrossOrigin
@Slf4j
@RequestMapping("/ordersRetreat")
public class ordersRetreatController {


    @Autowired
    ordersRetreatService ordersAftersalesService;




    @GetMapping("ordersRetreatLirt")
    @ApiOperation(value = " 订单管理的查询方法")
    @OptLog(modular = "订单管理", type = CommonConstants.ADD, describe = "查询订单")
    CommonResult ordersRetreatLirt(Integer userId , PageRequest pageResult) {
        PageResult pageResult1 = ordersAftersalesService.ordersRetreatLirt(pageResult,userId);
        return CommonResult.ok(pageResult1);
    }
    
    
    /**
     * @Author 小江
     * @Description //TODO 商品订单查询信息
     * @Date 14:14 2023/4/25
     **/
    @GetMapping("ordersRetreatComm")
    @ApiOperation(value = " 订单管理的查询方法")
    @OptLog(modular = "订单管理", type = CommonConstants.ADD, describe = "查询订单")
    CommonResult ordersRetreatComm(Integer userId, PageRequest pageResult){
        PageResult pageResult1 =ordersAftersalesService.ordersRetreatComm(userId,pageResult);
        return CommonResult.ok(pageResult1);
    }



    /**
     * @Author 小江
     * @Description //TODO diy订单驳回查询
     * @Date 14:26 2023/4/25
     **/
    @GetMapping("ordersRetreatDiy")
    @ApiOperation(value = " 订单管理的查询方法")
    @OptLog(modular = "订单管理", type = CommonConstants.ADD, describe = "查询订单")
    CommonResult ordersRetreatDiy(Integer userId, PageRequest pageResult){
        PageResult pageResult1 =ordersAftersalesService.ordersRetreatDiy(userId,pageResult);
        return CommonResult.ok(pageResult1);
    }


    /**
     * @Author 小江
     * @Description //TODO 修改驳回状态
     * @Date 14:56 2023/4/25
     **/
    @DeleteMapping("goodbyeDiy")
    @ApiOperation(value = "订单发货")
    @OptLog(modular = "订单发货", type = CommonConstants.ADD, describe = "通过发货方法")
    CommonResult goodbyeDiy(Integer id){
        int i = ordersAftersalesService.goodbyeDiy(id);
        log.info("删除diy商品");
        if (i > 0) {
            return CommonResult.ok();
        } else {
            return CommonResult.error();
        }
    }


    /**
     * @Author 小江
     * @Description //TODO 添加驳回信息
     * @Date 9:27 2023/4/26
     **/
    @PostMapping("amendUpdate")
    @ApiOperation(value = "添加驳回信息")
    @OptLog(modular = "添加驳回信息", type = CommonConstants.ADD, describe = "添加驳回信息")
    public CommonResult amendUpdate(OrdersRetreat ordersRetreat){
        int i = ordersAftersalesService.amendUpdate(ordersRetreat);
        if(i>0){
            return CommonResult.ok();
        }else{
            return CommonResult.error("修改失败");
        }
    }

}
